package cn.two.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;


import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.two.model.OaUser;
import cn.two.service.oaUserService;

@Controller
@RequestMapping("/login")
public class loginController {

	@Resource
	private oaUserService oaUserService;
	
	@RequestMapping("/userLogin")
	public String login(OaUser oaUser,HttpSession session,HttpServletResponse response) throws IOException{	
		
		OaUser oUser=oaUserService.login(oaUser);
		response.setContentType("text/html;charset=UTF-8");
		
		PrintWriter out =response.getWriter();
		
		if(oUser!=null){
			
			session.setAttribute("OaUser", oUser);
			
			return "checkApplyReim";
			
		}else{
			out.print("<script>alert('帐号或密码错误')</script>");
			return "userLogin";
		}
		
	
	}
	
	
}
